home *** CD-ROM | disk | FTP | other *** search
- From: fischer@Informatik.RWTH-Aachen.DE (Rainer Fischer)
- Message-ID: <4h4hmr$41o@news.rwth-aachen.de>
- X-Original-Date: 29 Feb 1996 15:45:31 GMT
- Path: in2.uu.net!bounce-back
- Date: 01 Mar 96 13:42:23 GMT
- Approved: fjh@cs.mu.oz.au
- Return-Path: <daemon@meeker.UCAR.EDU>
- Newsgroups: comp.std.c++
- Subject: overriding functions a la Stroustrup allowed?
- Organization: RWTH -Aachen / Rechnerbetrieb Informatik
- Keywords: overriding functions, static elements of classes
- X-Newsreader: NN version 6.5.0 #3 (NOV)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMTb+zOEDnX0m9pzZAQGCQAF/RxL5EMJdG4D2LkXOLuWG40g+Fw1qs6B7
- sBNqZWeqdTVxE3j7pVtXOF/RaR4KAnlV
- =D2R7
-
- In "Bjarne Stroustrup, The C++ programming language (german translation)"
- I found an example, which looks like this:
-
- struct base {
- base *next;
- static base *list;
-
- base() {next = list; list = this};
-
- virtual void function() = 0;
- // ...
- };
-
- class derived : public base {
- // ...
- public:
- void function();
- // ...
- };
-
-
- Two questions:
-
- 1) Does function() in class derived really override function() in base?
- Does the declaration in derived really say that function is not pure
- virtual and not virtual at all? I get a linker error-message, when I
- use such a construction without defining the overriding function, but
- neither a compiler error nor a warning. Is this correct?
-
- 2) What happens, when the very first object is created with a class
- derived from base? The constructor of base assignes list to next, but
- list is not yet initialized; so rubbish may be assigned to next. Is
- there no need to initialize list first, e.g. base *base::list = 0; some-
- where outside of base? I get a compiler error, if I don't do it.
-
- Thanks in advance for any help,
-
- Rainer Fischer.
- ---
- [ To submit articles: try just posting with your news-reader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu.
- ]
-